package com.mashibing.mall.product

import com.aliyun.oss.OSSClient
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.mashibing.mall.product.entity.BrandEntity
import com.mashibing.mall.product.service.BrandService
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

import javax.annotation.Resource

@SpringBootTest(classes = MallProductApplication.class)
class MallProductApplicationTests {

    @Autowired
    BrandService brandService;

    @Resource
    private OSSClient ossClient;

    @Test
    void contextLoads() {
        BrandEntity entity = new BrandEntity();
        entity.setName("魅族");
        brandService.save(entity);
    }

    @Test
    void selectAll() {
        List<BrandEntity> list = brandService.list();
        for (BrandEntity entity : list) {
            System.out.println(entity);
        }
    }

    @Test
    void selectById() {
        List<BrandEntity> list = brandService
                .list(new QueryWrapper<BrandEntity>().eq("brand_id",2));
        for (BrandEntity entity : list) {
            System.out.println(entity);
        }
    }

    @Test
    void testUploadFile() throws FileNotFoundException{
        InputStream inputStream = new FileInputStream("C:\\Users\\PC\\Desktop\\666.png")
        ossClient.putObject("mashibing-mall-rogzhongyang", "666.png", inputStream);
        ossClient.shutdown();
    }

}
